<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>积分商城添加</title>
    <link rel="stylesheet" href="__LAYUI__/css/layui.css">
    <style>
        
    </style>
</head>


<body>

    <div class="layui-container" style="margin-top: 20px;">
        <form class="layui-form" action="" method="post">



            <div class="layui-form-item">
                <label class="layui-form-label">积分</label>
                <div class="layui-input-block">
                    <input type="number" name="score" required lay-verify="required" placeholder="积分数量"
                        class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">金额</label>
                <div class="layui-input-block">
                    <input type="number" name="money" value="1" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <select name="status" required lay-verify="required">
                        <option value="1" selected>正常</option>
                        <option value="0">下架</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">权重</label>
                <div class="layui-input-block">
                    <input type="number" name="sort" value="100" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="addGoods">提交</button>
                </div>
            </div>
        </form>
    </div>
    <script src="__LAYUI__/layui.js"></script>
    <script>
        layui.use(['form', 'upload'], function () {
            var form = layui.form,
                upload = layui.upload;
            $ = layui.$

            form.on('submit(addGoods)', function (data) {
                console.log(data.field); 
                $.post('/admin/scoreShop/doAdd', data.field, function (response) {
                    if (response.code === 200) {
                        layer.msg('积分项目添加成功');
                    } else {
                        layer.msg('积分项目添加失败：' + response.msg);
                    }
                });
                return false; 
            });
        });
    </script>

</body>

</html>